#! /usr/bin/env python
# encoding: utf-8
import rospy
from sensor_msgs.msg import Image
import cv2
from cv_bridge import CvBridge


def publish_img(img_path):
    
    rospy.init_node('the_node', anonymous=False)

    cvb = CvBridge()

    msg = cvb.cv2_to_imgmsg(cv2.imread(img_path),"bgr8")

    img_pub_ = rospy.Publisher(rospy.get_name()+"/picture",Image,queue_size=10)

    rat = rospy.Rate(5) 

    while not rospy.is_shutdown():
        img_pub_.publish(msg)
        rat.sleep()


if __name__ == '__main__':
    publish_img("/home/ubuntu/Pictures/red_helmet.jpg")